<?php /* Smarty version 2.6.26, created on 2018-07-25 19:30:16
         compiled from E:%5CWWW%5C40.125.208.171%5Cvweb/member%5Ctemplates/distribute/index.html */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('modifier', 'img_size', 'E:\\WWW\\40.125.208.171\\vweb/member\\templates/distribute/index.html', 44, false),)), $this); ?>
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "index/header_shop.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?> 
<div class="tab_name"><span>分销管理</span></div>
<style type="text/css">
table{ } 
table tr th{ font-size:12px; padding:8px 0 6px; } 
table tbody tr th{ color:#000000; }
table tbody tr td{ text-align:center; color:#333; padding:0 0 8px 0;} 
a.simg{ width:60px; height:60px; line-height:60px; border:1px solid #efefef; padding:1px; float:left;}
a.simg img{ max-height:60px; max-width:60px; }
.ttl{ width:100%; padding:12px 0 0 5px; float:left;}
.ttl a{ text-align:left; font-size:12px; color:#333; padding:0 10px 0 10px; line-height:22px; float:left;  }
.ttl span{font-size:12px;line-height:22px; padding:0 10px 0 20px; color:#999999; text-align:left; float: left;} 

.intro{ width:440px; text-align:left; line-height:18px; padding:6px 0 0 15px; color:#999999; float:left;}
input.bfb{ padding:4px; text-align:center; }
input.submit2{ background:#00AB00; color:#fff; padding:5px 15px; float:left; }

.comm_box{ width:100%; float:left;  }
.comm_box span{ width:65px; margin-left:10px; float:left; }
.comm_box span i{ width:50px; padding:3px; border:1px solid #efefef; background:#f2f2f2; text-align:center; float:left; }
.comm_box span input{ width:50px; padding:3px; text-align:center; float:left; }
.comm_box a{ background:#D4D5D7; color:#333; padding:4px 5px 4px;border-radius:2px; float:left; } 
</style> 
<div class="actbtn">
	<a href="?m=distribute&a=add" class="add">添加分销</a>
</div>
<div class="lbox">
	<table class="ltable">
		<thead>
			<tr> 
				<th width="30">&nbsp;</th>
				<th>商品名</th> 
				<th width="100">推广数</th>
				<th width="100">佣金支出</th>
				<th width="120">佣金设置（百分比）</th> 
				<th width="100">取消分销</th> 
			</tr>
		</thead> 
		<tbody>  
	<?php if ($this->_tpl_vars['data']['list']): ?>	
		<?php $_from = $this->_tpl_vars['data']['list']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['i']):
?>		 
			<tr style="border-bottom:1px solid #efefef; border-top:none;"> 
				<td style="padding:15px 0 15px 10px;"> 
					 <a class="simg" href="index.php?m=goods&a=detail&id=<?php echo $this->_tpl_vars['i']['id']; ?>
"><img src="<?php echo $this->_tpl_vars['__IMG__']; ?>
<?php echo ((is_array($_tmp=$this->_tpl_vars['i']['images'])) ? $this->_run_mod_handler('img_size', true, $_tmp, '60x60') : $this->_plugins['modifier']['img_size'][0][0]->img_size($_tmp, '60x60')); ?>
"/></a>
				</td>
				<td valign="top">
					<div class="ttl"><a href="index.php?m=goods&a=detail&id=<?php echo $this->_tpl_vars['i']['id']; ?>
" target="_blank"><?php echo $this->_tpl_vars['i']['title']; ?>
</a></div> 
					<div class="intro">
						价格：<?php if ($this->_tpl_vars['i']['discount_price'] == ''): ?> <?php echo $this->_tpl_vars['i']['price']; ?>
<?php else: ?> <?php echo $this->_tpl_vars['i']['discount_price']; ?>
</s><?php endif; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						库存：<?php if ($this->_tpl_vars['i']['stock'] == '0'): ?>无货<?php else: ?><?php echo $this->_tpl_vars['i']['stock']; ?>
<?php endif; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						状态：<?php if ($this->_tpl_vars['i']['sell_status'] == '1'): ?>上架<?php else: ?>下架<?php endif; ?>
					</div>
				</td>  
				<td><?php echo $this->_tpl_vars['i']['total_num']; ?>
</td>
				<td><?php echo $this->_tpl_vars['i']['total_fee']; ?>
</td>
				<td>
					<div class="comm_box comm_box_<?php echo $this->_tpl_vars['i']['id']; ?>
" data-id="<?php echo $this->_tpl_vars['i']['id']; ?>
">
						<span><i><?php echo $this->_tpl_vars['i']['commission_rate']; ?>
</i></span><a href="javascript:;" class="comm_edit" data-id="<?php echo $this->_tpl_vars['i']['id']; ?>
" data-act="1">编辑</a>
					</div>
				</td> 
				<td><a href="javascript:;" class="edit cancel_distribute" data-id="<?php echo $this->_tpl_vars['i']['id']; ?>
">取消分销</a></td>
			</tr>
		<?php endforeach; endif; unset($_from); ?> 
	<?php else: ?> 
		<tr><td colspan="7" class="btm"><div class="nomsg"><i></i><span>暂无分销产品~</span></div></td></tr>
	<?php endif; ?>	
	</table>
	<?php if ($this->_tpl_vars['data']['page']): ?><div class="page"><?php echo $this->_tpl_vars['data']['page']; ?>
</div><?php endif; ?>
</div>
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "index/footer.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>
<script type="text/javascript">
$(function(){ 
	$(document).on('click',".comm_edit",function(){
		$this = $(this);
		var id = $this.attr('data-id');
		act_status = $this.attr('data-act'); 
		if(act_status == '1'){
			$this.html('保存').attr('data-act','0');
			rate_value = $(".comm_box_"+id+" span i").html(); 
			$(".comm_box_"+id+" span").html('<input type="text" class="comm_value" value="'+rate_value+'" min="0.01" max="100"/>'); 
		}else{
			rate_value = $(".comm_box_"+id+" span input").val(); 
			if(rate_value >=0.01 && rate_value <= 100){
				$.post('?m=distribute&a=commission_rate_save',{gid:id,rate_value:rate_value},function(data){ 
					if(data == '1'){
						$this.html('编辑').attr('data-act','1');
						$(".comm_box_"+id+" span").html('<i>'+rate_value+'</i>'); 			
					}else{
						alert('设置失败');
					}
				});
			}else{
				alert('佣金设置为0.01至100');
			} 
		}
	});
	// 取消分销
	$(".cancel_distribute").click(function(){
		var $this = $(this);
		var goods_id = $this.attr('data-id'); 
		$.post('?m=distribute&a=add_distribute',{gid:goods_id},function(result){ 
			data = jQuery.parseJSON(result); 
			if(data.error == '0'){
				location.reload();
			}else{
				$.alert(data.msg);
			}
		}); 
	}); 
	
});
</script>